<template>
    <div>
        <div class="container">
            <div class="handle-box">
              <el-row>
                <el-form :inline="true" :model="formInline" class="demo-form-inline">
                  <el-form-item label="所属市县/区">
                    <el-cascader
                       v-model="form.shixian"
                       :options="data"
                       :props="{value: 'name', label: 'name', children: 'children', checkStrictly: true}"
                       @change="handleChange"></el-cascader>
                  </el-form-item>
                  <el-form-item label="年度">
                    <el-date-picker
                          v-model="formInline.year"
                          type="year"
                          placeholder="选择年度">
                        </el-date-picker>
                  </el-form-item>
                   <el-form-item label="项目名称">
                        <el-input v-model="formInline.year" placeholder="项目名称"></el-input>
                  </el-form-item>
                  
                  <el-form-item>
                    <el-button type="primary" @click="onSubmit">查询</el-button>
                  </el-form-item>
                </el-form>
              </el-row>  
              <!-- <el-row type="flex" class="row-bg" justify="end">
               <el-button type="primary" icon="el-icon-plus" @click="handleEdit('', {}, false)">新增</el-button>
              </el-row> -->
                
            </div>
            <el-table
                :data="tableData"
                border
                class="table"
                ref="multipleTable"
                header-cell-class-name="table-header"
                @selection-change="handleSelectionChange"
            >   
                <el-table-column prop="xiangmumingcheng" label="项目名称" align="center" width="180">
                    <template slot-scope="scope">
                        <el-link @click="handleEdit('',scope.row, true)" type="primary">{{scope.row.xiangmumingcheng}}</el-link>
                    </template>
                </el-table-column>
                <el-table-column prop="year" label="年度"  align="center"></el-table-column>
                <el-table-column prop="leixing" label="项目类型"  align="center"></el-table-column>
                <el-table-column prop="shixian" label="所在市县/区"  align="center"></el-table-column>
                <el-table-column prop="weizhi" label="项目示意位置"  align="center"></el-table-column>
                <el-table-column prop="quyu" label="涉及区域"  align="center"></el-table-column>
                <el-table-column prop="shiliangtu" label="防治责任范围矢量图"  align="center"></el-table-column>
                <el-table-column prop="touzi" label="水保总投资"  align="center"></el-table-column>
                <el-table-column prop="tujian" label="图件"  align="center"></el-table-column>
                <el-table-column prop="danwei" label="受理审批项目" align="center">
                    <el-table-column prop="pfshijian" label="批复时间" align="center" width="110"></el-table-column>
                    <el-table-column prop="pfdanwei" label="批复单位" align="center"></el-table-column>
                    <el-table-column prop="pfwenhao" label="批复文号" align="center"></el-table-column>
                    <el-table-column prop="pfwenjan" label="批复文件" align="center"></el-table-column>
                    <el-table-column prop="pfgaizhang" label="批复文件盖章" align="center"></el-table-column>
                </el-table-column>
                <el-table-column prop="danwei" label="建设单位" align="center">
                    <el-table-column prop="jsmingcheng" label="单位名称" align="center"></el-table-column>
                    <el-table-column prop="jslianxiren" label="项目联系人" align="center"></el-table-column>
                    <el-table-column prop="jsdianhua" label="项目联系人电话" align="center"></el-table-column>
                </el-table-column>
                <el-table-column prop="danwei" label="特性信息" align="center">
                    <el-table-column prop="tzmianji" label="防治责任范围面积" align="center"></el-table-column>
                    <el-table-column prop="tzwenben" label="方案文本" align="center"></el-table-column>
                    <el-table-column prop="tzgaizhang" label="方案封面盖章" align="center"></el-table-column>
                    <el-table-column prop="tzqianzi" label="方案责任页签字" align="center"></el-table-column>
                </el-table-column>
                <el-table-column prop="danwei" label="方案编制单位" align="center">
                    <el-table-column prop="bzdanwei" label="编制单位" align="center"></el-table-column>
                    <el-table-column prop="bzlianxiren" label="单位联系人" align="center"></el-table-column>
                    <el-table-column prop="bzdianhua" label="单位联系人电话" align="center"></el-table-column>
                </el-table-column>
                <el-table-column prop="danwei" label="技术评审（市级）" align="center">
                    <el-table-column prop="jsdanwei" label="技术审查单位" align="center"></el-table-column>
                    <el-table-column prop="jsshijian" label="会议时间" align="center"></el-table-column>
                    <el-table-column prop="jsyijian" label="审查意见" align="center"></el-table-column>
                    <el-table-column prop="jsqianzi" label="审查意见签字" align="center"></el-table-column>
                </el-table-column>
                <!-- <el-table-column label="操作" width="180" align="center" fixed='right'>
                    <template slot-scope="scope">
                        <el-button
                            type="text"
                            icon="el-icon-edit"
                            @click="handleEdit(scope.$index, scope.row, false)"
                        >编辑</el-button>
                        <el-button
                            type="text"
                            icon="el-icon-delete"
                            class="red"
                            @click="handleDelete(scope.$index, scope.row)"
                        >删除</el-button>
                    </template>
                </el-table-column> -->
            </el-table>
            <div class="pagination">
                <el-pagination
                    background
                    layout="total, prev, pager, next"
                    :current-page="query.pageIndex"
                    :page-size="query.pageSize"
                    :total="pageTotal"
                    @current-change="handlePageChange"
                ></el-pagination>
            </div>
        </div>

        <!-- 编辑弹出框 -->
        <el-dialog :title="form.disabled ? '详情' : '编辑'" :visible.sync="editVisible" width="700px" append-to-body>
            <formDom @close="editVisible = false" :form="form"></formDom>
        </el-dialog>
    </div>
</template>

<script>
import {data} from '@/components/common/area';
import { fetchData } from '@/api/index';
import {GetFList} from '@/components/common/filter';
import formDom from './form' ;
export default {
    name: 'systemmanrole',
    components: {
      formDom  
    },
    data() {
        return {
            data: data,
            investSourceList: GetFList('investSource'),
            formInline: {
                year: ''
            },
            query: {
                address: '',
                name: '',
                pageIndex: 1,
                pageSize: 10
            },
            tableData: [{
                year: '2021',
                xiangmumingcheng: '瓦山区蓄水保土耕作项目',
                shixian: '南昌县',
                weizhi: '已填',
                quyu: '已填',
                shiliangtu: '无',
                touzi: '已填',
                tujian: 3,
                pfshijian: '2020-03-04',
                pfdanwei: '有',
                pfwenhao: '有',
                pfwenjan: '有',
                pfgaizhang: '是',
                jsmingcheng: '已填',
                jslianxiren: '已填',
                jsdianhua: '已填',
                tzmianji: '已填',
                tzwenben: '有',
                tzgaizhang: '有',
                tzqianzi: '有',
                bzdanwei: '已填',
                bzlianxiren: '已填',
                bzdianhua: '已填',
                jsdanwei: '已填',
                jsshijian: '已填',
                jsyijian: '有',
                jsqianzi: '是',
                leixing: '在建生产项目'
            }], 
            multipleSelection: [],
            delList: [],
            editVisible: false,
            pageTotal: 1,
            form: {},
            idx: -1,
            id: -1
        };
    },
    created() {
        let that=this
        //that.getData();
    },
    methods: {
        // 获取 easy-mock 的模拟数据
        getData() {
            fetchData(this.query).then(res => {
               
                this.tableData = res.list;
                this.pageTotal = res.pageTotal || 50;
            });
        },
        // 触发搜索按钮
        handleSearch() {
            this.$set(this.query, 'pageIndex', 1);
            this.getData();
        },
        // 删除操作
        handleDelete(index, row) {
            // 二次确认删除
            this.$confirm('确定要删除吗？', '提示', {
                type: 'warning'
            })
                .then(() => {
                    this.$message.success('删除成功');
                    this.tableData.splice(index, 1);
                })
                .catch(() => {});
        },
        // 多选操作
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },
        delAllSelection() {
            const length = this.multipleSelection.length;
            let str = '';
            this.delList = this.delList.concat(this.multipleSelection);
            for (let i = 0; i < length; i++) {
                str += this.multipleSelection[i].name + ' ';
            }
            this.$message.error(`删除了${str}`);
            this.multipleSelection = [];
        },
        // 编辑操作
        handleEdit(index, row, disabled) {
            this.idx = index;
            this.form = row;
            this.form = {...row, disabled}
            this.editVisible = true;
        },
        // 保存编辑
        saveEdit() {
            this.editVisible = false;
            this.$message.success(`修改第 ${this.idx + 1} 行成功`);
            this.$set(this.tableData, this.idx, this.form);
        },
        // 分页导航
        handlePageChange(val) {
            this.$set(this.query, 'pageIndex', val);
            this.getData();
        },
        onSubmit() {},
    }
};
</script>

<style scoped>
.handle-box {
    margin-bottom: 20px;
}

.handle-select {
    width: 120px;
}

.handle-input {
    width: 300px;
    display: inline-block;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
</style>
